package org.example.service.impl;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.example.service.OrderRemoteService;
import org.example.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private OrderRemoteService orderRemoteService;

    /**
     * Trace注解将方法加入追踪链路
     */
    @Override
    @Trace
    // 记录参数: value=arg[0], 0为参数下标,key = 方法名
    // 记录返回值: value=returnObj,key = 方法名
    @Tags({ @Tag(key = "findOrderByUserId", value = "arg[0]"), @Tag(key = "findOrderByUserId", value = "returnedObj")})
    public String findOrderByUserId(String userId) {
        return orderRemoteService.findOrderByUserId(userId);
    }
}
